public class Solution {
    public int peakIndexInMountainArray(int[] arr) {
        int left = 1,right = arr.length - 2;
        while(left < right) {
            int mid = left + (right - left + 1) / 2;
            if(arr[mid] < arr[mid- 1])  right = mid - 1;
            else left = mid;
        }
        return right;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] arr = {0,10,5,2};
        System.out.println(solution.peakIndexInMountainArray(arr));
    }
}
